Skip to content

test(selfhost): cover env_get and require_cmd in selfhost-deploy-common - #7945

Merged
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
real-venus:fix/selfhost-deploy-common-test-coverage-7769
Jul 21, 2026
Merged

test(selfhost): cover env_get and require_cmd in selfhost-deploy-common#7945
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
real-venus:fix/selfhost-deploy-common-test-coverage-7769

Conversation

@real-venus

Copy link
Copy Markdown
Contributor

Summary

Closes #7769 — adds unit coverage for the two remaining untested functions in scripts/lib/selfhost-deploy-common.sh (env_get and require_cmd), matching the existing maybe_infisical_run / env_put / compose_file_args harness already in test/unit/selfhost-deploy-common.test.ts.

env_put (#7766) and compose_file_args (#7765) already got their coverage from those bug-fix PRs, so per the issue's "check before duplicating" note they're left untouched — this fills in only the genuinely-uncovered two.

What's covered

require_cmd

  • present command → silent no-op, exit 0
  • missing command → exit 1 with error: required command not found: <cmd> on stderr

env_get

  • plain unquoted value for a present key
  • strips one pair of surrounding double or single quotes
  • trims whitespace around the value and matches a key on an indented line
  • skips comment lines and returns the first matching assignment
  • absent key → returns 1, no output
  • absent file → returns 1, no output
  • falls back to $ENV_FILE when no file argument is given

Notes

  • Also adds inline contract comments above require_cmd and env_get, matching how the same file already documents env_put / maybe_infisical_run / compose_file_args.
  • Test-only + docs; no behavior change to the library or its callers. bash -n clean; selfhost:env-reference:check unaffected.

Adds unit coverage for the two remaining untested functions in
scripts/lib/selfhost-deploy-common.sh, following the existing
maybe_infisical_run / env_put / compose_file_args harness in the same file:

- require_cmd: present (silent no-op) and missing (exit 1 + stderr message).
- env_get: plain value, single/double-quote stripping, whitespace trim + indented
  key, comment-line skipping + first-match, absent key -> 1, absent file -> 1, and
  the $ENV_FILE fallback when no file arg is given.

Also documents both functions' contracts inline (the file already documents
env_put / maybe_infisical_run / compose_file_args this way). env_put (JSONbored#7766) and
compose_file_args (JSONbored#7765) already have coverage from their bug-fix PRs, so they
are left as-is per the issue's "don't duplicate" note.

Closes JSONbored#7769
@real-venus
real-venus requested a review from JSONbored as a code owner July 21, 2026 20:11
@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@codecov

codecov Bot commented Jul 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.79%. Comparing base (4f87f1a) to head (cf349d0).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #7945       +/-   ##
===========================================
+ Coverage   78.19%   91.79%   +13.60%     
===========================================
  Files         733      733               
  Lines       75143    75143               
  Branches    22917    22917               
===========================================
+ Hits        58761    68981    +10220     
+ Misses      13419     5083     -8336     
+ Partials     2963     1079     -1884     
Flag Coverage Δ
shard-1 58.33% <ø> (?)
shard-2 52.12% <ø> (ø)
shard-3 50.01% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.
see 234 files with indirect coverage changes

@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 21, 2026
@loopover-orb

loopover-orb Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Tip

✅ LoopOver review result - approve/merge recommended

Review updated: 2026-07-21 20:33:01 UTC

2 files · 1 AI reviewer · no blockers · readiness 100/100 · CI green · clean

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
This is a test-only PR that adds unit coverage for require_cmd and env_get in scripts/lib/selfhost-deploy-common.sh, plus inline contract comments matching the existing documentation style for env_put/maybe_infisical_run/compose_file_args. The tests correctly exercise the real awk-based parsing logic (quote stripping, whitespace trimming, comment skipping, first-match semantics, ENV_FILE fallback) by sourcing the actual library and invoking the functions directly, not by mocking or fabricating unreachable states. The library itself is unchanged (+6/-0, comments only), so there's no behavior change to verify beyond the tests being real and well-targeted.

Nits — 3 non-blocking
  • scripts/lib/selfhost-deploy-common.sh: the new require_cmd/env_get comments are good but slightly verbose relative to the function bodies — consistent with the file's existing style though, so not worth changing.
  • test/unit/selfhost-deploy-common.test.ts: the env_get tests don't cover a key whose name is a substring of another key (e.g. FOO vs FOOBAR) to confirm the awk regex anchors on the full key, though the awk pattern's `key "[[:space:]]*="` construction makes this a low-risk gap.
  • Consider adding one case where SPACED-style trimming interacts with a quoted value (e.g. `KEY = " value "`) to confirm trim-then-strip-quotes ordering, though this is a minor coverage nicety, not a requirement.

Decision drivers

  • ✅ Code review — No blockers (1 reviewer)
  • ✅ Gate result — Passing (No configured blocker found.)
Context & advisory signals — never blocks the verdict
Signal Result Evidence
Linked issue ✅ Linked #7769
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ✅ 20/20 Low review scope from cached public metadata (1 linked issue).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 111 registered-repo PR(s), 51 merged, 19 issue(s).
Contributor context ✅ Confirmed Gittensor contributor real-venus; Gittensor profile; 111 PR(s), 19 issue(s).
Improvement ℹ️ Insufficient signal risk: clean · value: insufficient-signal · LLM: moderate
Linked issue satisfaction

Addressed
The PR adds thorough test coverage for env_get and require_cmd matching the existing maybe_infisical_run harness, and per the issue's own note defers to the companion PRs that already cover env_put and compose_file_args, together satisfying all four functions' coverage.

Review context
  • Author: real-venus
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: TypeScript, JavaScript, Python, Rust, CSS, MDX, Svelte, Swift
  • Official Gittensor activity: 111 PR(s), 19 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Keep the PR focused and include validation evidence before maintainer review.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.
🧪 Chat with LoopOver

Ask LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.

  • @loopover ask &lt;question&gt; answers contribution-quality Q&A with source citations and freshness.
  • @loopover chat &lt;question&gt; answers in natural prose from cached decision-pack facts via local inference (maintainer/collaborator; read-only).
  • A plain-language @loopover mention with a real question is routed to the closest matching read-only command automatically — no exact syntax required.

Full command reference: https://loopover.ai/docs/loopover-commands

🧪 Experimental — new and may change.

🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed


💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →.

Checked by LoopOver, a quiet PR intelligence layer for OSS maintainers.

  • Re-run LoopOver review

@loopover-orb loopover-orb Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LoopOver approves — the gate is satisfied and CI is green.

@loopover-orb
loopover-orb Bot merged commit 6c20673 into JSONbored:main Jul 21, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

scripts/lib/selfhost-deploy-common.sh: 3 of 4 functions have zero test coverage

1 participant